﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace IcqSharp
{
    public class DataChannelHandler //: ChannelHandler
    {
        public static void Handle(MemoryStream stream)
        {
            var header = new SNACHeader(stream);

            // Failed to parse SNAC header
            if (!header.Valid) Debugger.Break();

            switch (header.Family)
            {
                case (UInt16)Family.Service:
                    ServiceFamilyHandler.Handle(stream, header); break;

                case (UInt16)Family.Location:
                    LocationFamilyHandler.Handle(stream, header); break;

                case (UInt16)Family.Buddy:
                    BuddyFamilyHandler.Handle(stream, header); break;

                case (UInt16)Family.Message:
                    //HandleMsgFamily(header);
                    break;

                case (UInt16)Family.BOS:
                    //HandleBosFamily(header);
                    break;

                case (UInt16)Family.Lookup:
                    //HandleLookupFamily(header);
                    break;

                case (UInt16)Family.Stats:
                    //HandleStatusFamily(header);
                    break;

                case (UInt16)Family.Lists:
                    //HandleServCListFamily(header);
                    break;

                case (UInt16)Family.Extensions:
                    //HandleIcqExtensionsFamily(header);
                    break;

                case (UInt16)Family.Authorization:
                    AuthorizationFamilyHandler.Handle(stream, header); break;

                default:
                    //NetLog_Server("Ignoring SNAC(x%02X,x%02X) - FAMILYx%02X not implemented", snacHeader.wFamily, snacHeader.wSubtype, snacHeader.wFamily);
                    break;
            }
        }

    }
}
